<script language="JavaScript">
function DatePosition(dateString,value) {



    var now = new Date();
    var today = new Date(now.getYear(),now.getMonth(),now.getDate());
    var century = parseInt(now.getYear()/100)*100;
        
   
        var date = new Date(dateString.substring(6,10),
                            dateString.substring(3,5)-1,
                            dateString.substring(0,2));

	if(value == 1)
	{
	    if (date > today)
	    {
	      alert('The visitdate must be equal to or less than todays date.');
	      document.form.txtVisitDate.select();
	      document.form.txtVisitDate.focus();  
	    }
	}
	
	if(value == 2)
	{
	    if (date > today)
	    {
	      alert('The birth date must be equal to or less than todays date.');
	      document.form.txtDob.select();
	      document.form.txtDob.focus();  
	    }
	}
	
	if(value == 3)
	{
	    if (date < today)
	    {
	      alert('The whendue date must be equal to or greater than todays date.');
	       
	    }
	}
	
   
}

</script>

<script language="javascript">



<!--dollar value-->

var prefix="$"

var wd

function parseelement(thisone){

if (thisone.value.charAt(0)=="$")

return thisone

wd="w"

var tempnum=thisone.value

for (i=0;i<tempnum.length;i++){

if (tempnum.charAt(i)=="."){

wd="d"

break

}

}

if (wd=="w")

thisone.value=tempnum+".00"

else{

if (tempnum.charAt(tempnum.length-2)=="."){

thisone.value=tempnum+"0"

}

else{

tempnum=Math.round(tempnum*100)/100

thisone.value=tempnum

	<!--

if(thisone.value == ".00")

	{

		thisone.value="0.00"

	}

-->

}

}

}

</SCRIPT>



<!--check if the value is a number-->

<SCRIPT>

function checknumber(pnum){

var x=pnum.value

var anum=/(^\d+$)|(^\d+\.\d+$)/

if (anum.test(x))

{

testresult=true

}

else{

alert("Please input a valid number!")

testresult=false

}

return (testresult)

}

</SCRIPT>

<SCRIPT>

function checkban(pnum){

if (document.layers||document.all||document.getElementById)

return checknumber(pnum)

else

return true

}



</script>

<SCRIPT>

function checknumberdollar(pnum){

var x=pnum.value

var anum=/(^\d+$)|(^\d+\.\d+$)/

if (anum.test(x))

{

parseelement(pnum)

testresult=true

}

else{

alert("Please input a valid number!")

testresult=false

}

return (testresult)

}

</SCRIPT>

<SCRIPT>

function checkbandollar(pnum){

if (document.layers||document.all||document.getElementById)

return checknumberdollar(pnum)

else

return true

}



</script>





<!--make the initial alphabet uppercase-->

<SCRIPT LANGUAGE="JavaScript">

function changeCase(frmObj) {

var index;

var tmpStr;

var tmpChar;

var preString;

var postString;

var strlen;

tmpStr = frmObj.value.toLowerCase();

strLen = tmpStr.length;

if (strLen > 0)  {

for (index = 0; index < strLen; index++)  {

if (index == 0)  {

tmpChar = tmpStr.substring(0,1).toUpperCase();

postString = tmpStr.substring(1,strLen);

tmpStr = tmpChar + postString;

}

else {

tmpChar = tmpStr.substring(index, index+1);

if (tmpChar == " " && index < (strLen-1))  {

tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();

preString = tmpStr.substring(0, index+1);

postString = tmpStr.substring(index+2,strLen);

tmpStr = preString + tmpChar + postString;

         }

      }

   }

}



frmObj.value = tmpStr;

}



</script>





<!--element focus-->

<SCRIPT LANGUAGE="JavaScript">



 function putFocus(formInst, elementInst) {

  if (document.forms.length > 0) {

   document.forms[formInst].elements[elementInst].focus();

  }

 }



</script>



<!--help provider-------->

<SCRIPT LANGUAGE="JavaScript">



function explain(name,output,msg) {

newwin = window.open('','','top=150,left=150,width=325,height=300');

if (!newwin.opener) newwin.opener = self;

with (newwin.document)

{

open();

write('<html>');

write('<body onLoad="document.form.box.focus()" background="./images/10/main.jpg"><form name=form ><font size="2">' + msg + '<br>');

write('<p>You may enter your ' + name + ' here and it will be copied into the form for you.');

write('<p><center>' + name + ':  <input type=text name=box size=10 onKeyUp=' + output + '=this.value>');

write('<p><input type=button value="Click to close when finished" onClick=window.close()>');

write('</center></form></body></html>');

close();

   }

}

</script>







<!-----------------------Validation OF Date---------------------------------------------------------->

<SCRIPT LANGUAGE="JavaScript">



var isNav4 = false, isNav5 = false, isIE4 = false

var strSeperator = "/"; 

// If you are using any Java validation on the back side you will want to use the / because 

// Java date validations do not recognize the dash as a valid date separator.

var vDateType = 3; // Global value for type of date format

//                1 = mm/dd/yyyy

//                2 = yyyy/dd/mm  (Unable to do date check at this time)

//                3 = dd/mm/yyyy

var vYearType = 4; //Set to 2 or 4 for number of digits in the year for Netscape

var vYearLength = 2; // Set to 4 if you want to force the user to enter 4 digits for the year before validating.

var err = 0; // Set the error code to a default of zero

if(navigator.appName == "Netscape") {

if (navigator.appVersion < "5") {

isNav4 = true;

isNav5 = false;

}

else

if (navigator.appVersion > "4") {

isNav4 = false;

isNav5 = true;

   }

}

else {

isIE4 = true;

}









function DateFormat(vDateName, vDateValue, e, dateCheck, dateType) {

vDateType = dateType;

// vDateName = object name

// vDateValue = value in the field being checked

// e = event

// dateCheck 

// True  = Verify that the vDateValue is a valid date

// False = Format values being entered into vDateValue only

// vDateType

// 1 = mm/dd/yyyy

// 2 = yyyy/mm/dd

// 3 = dd/mm/yyyy

//Enter a tilde sign for the first number and you can check the variable information.

if (vDateValue == "~") {

alert("AppVersion = "+navigator.appVersion+" \nNav. 4 Version = "+isNav4+" \nNav. 5 Version = "+isNav5+" \nIE Version = "+isIE4+" \nYear Type = "+vYearType+" \nDate Type = "+vDateType+" \nSeparator = "+strSeperator);

vDateName.value = "";

vDateName.focus();

return true;

}

var whichCode = (window.Event) ? e.which : e.keyCode;

// Check to see if a seperator is already present.

// bypass the date if a seperator is present and the length greater than 8

if (vDateValue.length > 8 && isNav4) {

if ((vDateValue.indexOf("-") >= 1) || (vDateValue.indexOf("/") >= 1))

return true;

}

//Eliminate all the ASCII codes that are not valid

var alphaCheck = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-";

if (alphaCheck.indexOf(vDateValue) >= 1) {

if (isNav4) {

vDateName.value = "";

vDateName.focus();

vDateName.select();

return false;

}

else {

vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));

return false;

   }

}

if (whichCode == 8) //Ignore the Netscape value for backspace. IE has no value

return false;

else {

//Create numeric string values for 0123456789/

//The codes provided include both keyboard and keypad values

var strCheck = '47,48,49,50,51,52,53,54,55,56,57,58,59,95,96,97,98,99,100,101,102,103,104,105';

if (strCheck.indexOf(whichCode) != -1) {

if (isNav4) {

if (((vDateValue.length < 6 && dateCheck) || (vDateValue.length == 7 && dateCheck)) && (vDateValue.length >=1)) {

alert("Invalid Date\nPlease Re-Enter");

vDateName.value = "";

vDateName.focus();

vDateName.select();

return false;

}

if (vDateValue.length == 6 && dateCheck) {

var mDay = vDateName.value.substr(2,2);

var mMonth = vDateName.value.substr(0,2);

var mYear = vDateName.value.substr(4,4)

//Turn a two digit year into a 4 digit year

if (mYear.length == 2 && vYearType == 4) {

var mToday = new Date();

//If the year is greater than 30 years from now use 19, otherwise use 20

var checkYear = mToday.getFullYear() + 30; 

var mCheckYear = '20' + mYear;

if (mCheckYear >= checkYear)

mYear = '19' + mYear;

else

mYear = '20' + mYear;

}

var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;

if (!dateValid(vDateValueCheck)) {

alert("Invalid Date\nPlease Re-Enter");

vDateName.value = "";

vDateName.focus();

vDateName.select();

return false;

}

return true;

}

else {

// Reformat the date for validation and set date type to a 1

if (vDateValue.length >= 8  && dateCheck) {

if (vDateType == 1) // mmddyyyy

{

var mDay = vDateName.value.substr(2,2);

var mMonth = vDateName.value.substr(0,2);

var mYear = vDateName.value.substr(4,4)

vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;

}

if (vDateType == 2) // yyyymmdd

{

var mYear = vDateName.value.substr(0,4)

var mMonth = vDateName.value.substr(4,2);

var mDay = vDateName.value.substr(6,2);

vDateName.value = mYear+strSeperator+mMonth+strSeperator+mDay;

}

if (vDateType == 3) // ddmmyyyy

{

var mMonth = vDateName.value.substr(2,2);

var mDay = vDateName.value.substr(0,2);

var mYear = vDateName.value.substr(4,4)

vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;

}

//Create a temporary variable for storing the DateType and change

//the DateType to a 1 for validation.

var vDateTypeTemp = vDateType;

vDateType = 1;

var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;

if (!dateValid(vDateValueCheck)) {

alert("Invalid Date\nPlease Re-Enter");

vDateType = vDateTypeTemp;

vDateName.value = "";

vDateName.focus();

vDateName.select();

return false;

}

vDateType = vDateTypeTemp;

return true;

}

else {

if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {

alert("Invalid Date\nPlease Re-Enter");

vDateName.value = "";

vDateName.focus();

vDateName.select();

return false;

         }

      }

   }

}

else {

// Non isNav Check

if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {

alert("Invalid Date\nPlease Re-Enter");

vDateName.value = "";

vDateName.focus();

return true;

}

// Reformat date to format that can be validated. mm/dd/yyyy

if (vDateValue.length >= 8 && dateCheck) {

// Additional date formats can be entered here and parsed out to

// a valid date format that the validation routine will recognize.

if (vDateType == 1) // mm/dd/yyyy

{

var mMonth = vDateName.value.substr(0,2);

var mDay = vDateName.value.substr(3,2);

var mYear = vDateName.value.substr(6,4)

}

if (vDateType == 2) // yyyy/mm/dd

{

var mYear = vDateName.value.substr(0,4)

var mMonth = vDateName.value.substr(5,2);

var mDay = vDateName.value.substr(8,2);

}

if (vDateType == 3) // dd/mm/yyyy

{

var mDay = vDateName.value.substr(0,2);

var mMonth = vDateName.value.substr(3,2);

var mYear = vDateName.value.substr(6,4)

}

if (vYearLength == 4) {

if (mYear.length < 4) {

alert("Invalid Date\nPlease Re-Enter");

vDateName.value = "";

vDateName.focus();

return true;

   }

}

// Create temp. variable for storing the current vDateType

var vDateTypeTemp = vDateType;

// Change vDateType to a 1 for standard date format for validation

// Type will be changed back when validation is completed.

vDateType = 1;

// Store reformatted date to new variable for validation.

var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;

if (mYear.length == 2 && vYearType == 4 && dateCheck) {

//Turn a two digit year into a 4 digit year

var mToday = new Date();

//If the year is greater than 30 years from now use 19, otherwise use 20

var checkYear = mToday.getFullYear() + 30; 

var mCheckYear = '20' + mYear;

if (mCheckYear >= checkYear)

mYear = '19' + mYear;

else

mYear = '20' + mYear;

vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;

// Store the new value back to the field.  This function will

// not work with date type of 2 since the year is entered first.

if (vDateTypeTemp == 1) // mm/dd/yyyy

vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;

if (vDateTypeTemp == 3) // dd/mm/yyyy

vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;

} 

if (!dateValid(vDateValueCheck)) {

alert("Invalid Date\nPlease Re-Enter");

vDateType = vDateTypeTemp;

vDateName.value = "";

vDateName.focus();

return true;

}

vDateType = vDateTypeTemp;

return true;

}

else {

if (vDateType == 1) {

if (vDateValue.length == 2) {

vDateName.value = vDateValue+strSeperator;

}

if (vDateValue.length == 5) {

vDateName.value = vDateValue+strSeperator;

   }

}

if (vDateType == 2) {

if (vDateValue.length == 4) {

vDateName.value = vDateValue+strSeperator;

}

if (vDateValue.length == 7) {

vDateName.value = vDateValue+strSeperator;

   }

} 

if (vDateType == 3) {

if (vDateValue.length == 2) {

vDateName.value = vDateValue+strSeperator;

}

if (vDateValue.length == 5) {

vDateName.value = vDateValue+strSeperator;

   }

}

return true;

   }

}

if (vDateValue.length == 10&& dateCheck) {

if (!dateValid(vDateName)) {

// Un-comment the next line of code for debugging the dateValid() function error messages

//alert(err);  

alert("Invalid Date\nPlease Re-Enter");

vDateName.focus();

vDateName.select();

   }

}

return false;

}

else {

// If the value is not in the string return the string minus the last

// key entered.

if (isNav4) {

vDateName.value = "";

vDateName.focus();

vDateName.select();

return false;

}

else

{

vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));

return false;

         }

      }

   }

}





</script>



<script>

function dateValid(objName) {

var strDate;

var strDateArray;

var strDay;

var strMonth;

var strYear;

var intday;

var intMonth;

var intYear;

var booFound = false;

var datefield = objName;

var strSeparatorArray = new Array("-"," ","/",".");

var intElementNr;

// var err = 0;

var strMonthArray = new Array(12);

strMonthArray[0] = "Jan";

strMonthArray[1] = "Feb";

strMonthArray[2] = "Mar";

strMonthArray[3] = "Apr";

strMonthArray[4] = "May";

strMonthArray[5] = "Jun";

strMonthArray[6] = "Jul";

strMonthArray[7] = "Aug";

strMonthArray[8] = "Sep";

strMonthArray[9] = "Oct";

strMonthArray[10] = "Nov";

strMonthArray[11] = "Dec";

//strDate = datefield.value;

strDate = objName;

if (strDate.length < 1) {

return true;

}

for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {

if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {

strDateArray = strDate.split(strSeparatorArray[intElementNr]);

if (strDateArray.length != 3) {

err = 1;

return false;

}

else {

strDay = strDateArray[0];

strMonth = strDateArray[1];

strYear = strDateArray[2];

}

booFound = true;

   }

}

if (booFound == false) {

if (strDate.length>5) {

strDay = strDate.substr(0, 2);

strMonth = strDate.substr(2, 2);

strYear = strDate.substr(4);

   }

}

//Adjustment for short years entered

if (strYear.length == 2) {

strYear = '20' + strYear;

}

strTemp = strDay;

strDay = strMonth;

strMonth = strTemp;

intday = parseInt(strDay, 10);

if (isNaN(intday)) {

err = 2;

return false;

}

intMonth = parseInt(strMonth, 10);

if (isNaN(intMonth)) {

for (i = 0;i<12;i++) {

if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {

intMonth = i+1;

strMonth = strMonthArray[i];

i = 12;

   }

}

if (isNaN(intMonth)) {

err = 3;

return false;

   }

}

intYear = parseInt(strYear, 10);

if (isNaN(intYear)) {

err = 4;

return false;

}

if (intMonth>12 || intMonth<1) {

err = 5;

return false;

}

if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {

err = 6;

return false;

}

if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {

err = 7;

return false;

}

if (intMonth == 2) {

if (intday < 1) {

err = 8;

return false;

}

if (LeapYear(intYear) == true) {

if (intday > 29) {

err = 9;

return false;

   }

}

else {

if (intday > 28) {

err = 10;

return false;

      }

   }

}

return true;

}





</script>



<script>

function LeapYear(intYear) {

if (intYear % 100 == 0) {

if (intYear % 400 == 0) { return true; }

}

else {

if ((intYear % 4) == 0) { return true; }

}

return false;

}



</script>





<!----verify if everything has been inputed---->

<SCRIPT LANGUAGE="JavaScript">



function verify() {

var themessage = "You are required to complete the following fields: \n";


	if (document.form.txtCurrentAddress.value=="") {
	
	themessage = themessage + " - Address\n";
	
	}
	
	if (document.form.txtCurrentSuburb.value=="") {
	
	themessage = themessage + " - Suburb\n";
	
	}
	
	
	
	if (document.form.txtCurrentPostCode.value=="") {
	
	themessage = themessage + " - Post Code\n";
	
	}
	
	if (document.form.txtPhone.value=="") {

	themessage = themessage + " - Phone number\n";
	
	}
	
	
	if (document.form.txtVisitDate.value=="") {
	
	themessage = themessage + " - Visit Date\n";
	
	}
	
	
	if (document.form.txtErReason.value=="") {
	
	themessage = themessage + " - Presenting Problem and other issues (ER)\n";
	
	}
	
	if (document.form.txtAdults.value=="") {

	themessage = themessage + " - No of Adults assistted\n";
	
	}
	
	 
	
	if (document.form.txtChildren.value=="") {
	
	themessage = themessage + " - No of Children assistted\n";
	
	}
	
	
if (checkToggle('form','emergencyReliefs[]') == false) {
	themessage = themessage + " - At least 1 reason for seeking assistance\n";
}

	
	if (document.form.txtActionTaken.value=="") {
	
	themessage = themessage + " - Action Taken\n";
	
	}
	
	if (document.form.txtInterviewer.value=="") {
	
	themessage = themessage + " - Interviewer\n";
	
	}
	
	
	if (document.form.txtAdults.value=="0" && document.form.txtChildren.value=="0") {
	
	themessage = themessage + " \n Please Note:\n Both Number of Adults and children cant be zero\n";
	
	}


	if (themessage == "You are required to complete the following fields: \n") 
	{
	
	document.form.submit();
	
	}
	
	else
	{
	
	alert(themessage);
	return false;
	}

}



</script>

<!--
script to check that atleast one checkbox for reason for seekign assistance has been checked
-->
<script>
function checkToggle (theForm,theCheckbox) {
    // Set target elements
    var theElements = document.forms[theForm].elements[theCheckbox];
   // Loop through the elements
   
   
   var check = 0;
    for (var count = 0; count < theElements.length; count++) 
    {
    	
         if(theElements[count].checked == true)
         {
         	check++;
         }
    }
    
    if(check >0)
    {
    	return true;
    }
    else
    {
    	return false;

    }
} 
</script>







<!------ to remove the white spaces------>

<SCRIPT language="javascript">

function remove_XS_whitespace(item)

{

 item.value = item.value.replace(/\r/g, " ");

  item.value = item.value.replace(/[^ A-Za-z0-9`~!@#\$%\^&\*\(\)-_=\+\\\|\]\[\}\{'";:\?\/\.>,<]/g, "");

  item.value = item.value.replace(/'/g, "");

  item.value = item.value.replace(/ +/g, " ");  

  item.value = item.value.replace(/^\s/g, "");

  item.value = item.value.replace(/\s$/g, "");	

  if (item.value == ' '){item.value = ''};

}

</SCRIPT>





<!----checks if only aplhabets are included in fields such as name-->

<SCRIPT language="javascript">

function checkalpha(item)

{

var i=0;

for(i=0;i<=item.length-1;i++)

{

	if(!isAlpha(item.substring(i,i+1)))

	{

	alert('only aphabets please');

	return false;

	}

	else

	{

	return true;

	}

}

	

}

</SCRIPT>





<!---- the following scripts is for acquiring the other types of different combo boxes.---->

<SCRIPT>

function otherhousingtype(sel) 

{ 
	option=document.form.cmbHousingType.options[document.form.cmbHousingType.selectedIndex].text;
	txt=option;
	
	if(txt == 'Other')
	{
		message='Enter Other Housing type here';
		document.form.txtOtherHousingType.value=message;
		document.form.txtOtherHousingType.select();
		document.form.txtOtherHousingType.focus();
	}
	else
	{
		document.form.txtOtherHousingType.value="";
		document.form.cmbHousingType.focus();
	}

}

</SCRIPT>





<SCRIPT>

function otherincomestatus(sel) 

{ 

	option=document.form.cmbIncomeStatus.options[document.form.cmbIncomeStatus.selectedIndex].text;
	txt=option;
	
	if(txt == 'Other')
	{
		message='Enter Other Income Status type here';
		document.form.txtOtherIncomeStatusType.value=message;
		document.form.txtOtherIncomeStatusType.select();
		document.form.txtOtherIncomeStatusType.focus();
	}
	else
	{
		document.form.txtOtherIncomeStatusType.value="";
		document.form.cmbIncomeStatus.focus();
	}


}

</SCRIPT>



<SCRIPT language="javascript">

function otheridtype(sel) 

{ 
	option=document.form.cmbIdType.options[document.form.cmbIdType.selectedIndex].text;
	txt=option;
	
	if(txt == 'Other')
	{
		message='Enter Other ID type here';
		document.form.txtOtherIdType.value=message;
		document.form.txtOtherIdType.select();
		document.form.txtOtherIdType.focus();
	}
	else
	{
		document.form.txtOtherIdType.value="";
		document.form.cmbIdType.focus();
	}


}

</SCRIPT>

<SCRIPT language="javascript">

function chequenumber(sel) 

{ 
	option=document.form.txtChequePayee.value;
	txt=option;
	
	if(txt == "")
	{
		
	}
	else
	{
		message='Enter Check Number here';
		document.form.txtErAmountRecieptNo.value=message;
		document.form.txtErAmountRecieptNo.select();
		document.form.txtErAmountRecieptNo.focus();
	}


}

</SCRIPT>


<SCRIPT>
function checkvalue(sel) 

{ 
	option=document.form.txtErAmountRecieptNo.value;
	txt1=option;
	
	option=document.form.txtChequePayee.value;
	txt2=option;
	
	if(txt1 == "Enter Check Number here" && txt2 != "")
	{
		message='Enter Check Number here';
		document.form.txtErAmountRecieptNo.value=message;
		document.form.txtErAmountRecieptNo.select();
		document.form.txtErAmountRecieptNo.focus();
	}
	else
	{
		document.form.txtErAmountRecieptNo.value="";
		
	}


}

</SCRIPT>



<SCRIPT>
function checkpayee(sel) 

{ 
	option=document.form.txtErAmountRecieptNo.value;
	txt1=option;
	
	option=document.form.txtChequePayee.value;
	txt2=option;
	
	if(txt2 == "")
	{
		message='Please Enter Check Payee and Number';
		document.form.txtErAmountRecieptNo.value="";
				
		document.form.txtChequePayee.focus();
		alert(message);
		document.form.txtChequePayee.focus();
		return false;
	}
	else
	{
		
		
	}


}

</SCRIPT>
<script>
function disableassistance(theForm,theCheckbox) {
   
    var theElements = document.forms[theForm].elements[theCheckbox];
      
   var check = 0;   
    for (var count = 0; count < theElements.length; count++) 
    {  
    	if(theElements[count].value == '0' || theElements[count].value == '0.00')
    	{
       		//theElements[count].disabled = true;        
       		//check =0;
    	}
    	else
    	{
    		//alert(' Please make sure that dollar amounts for all types of assistance is zero');
    		check ++;
    	}
    }
    
    if(check > 0)
    {
    	alert(' Please make sure that dollar amounts for all types of assistance is zero');
    }
    else
    {
    	for (var count = 0; count < theElements.length; count++) 
    	{
    		theElements[count].disabled = true;        
    	}
    	
    	document.form.txtChequePayee.disabled = true;
    	document.form.txtErAmountRecieptNo.disabled = true;
    	document.form.txtReasonChequePayment.disabled = true;
    	document.form.txtOtherPaymentType.disabled = true;
    }    	
    
} 
</script>

<script>
function enableassistance(theForm,theCheckbox) {
    // Set target elements
    var theElements = document.forms[theForm].elements[theCheckbox];
   // Loop through the elements
   
   
   var check = 0;
   
   
    for (var count = 0; count < theElements.length; count++) 
    {
    	
       theElements[count].disabled = false;
      
        
    }
   	   document.form.txtChequePayee.disabled = true;
    	document.form.txtErAmountRecieptNo.disabled = true;
    	document.form.txtReasonChequePayment.disabled = true;
    	document.form.txtOtherPaymentType.disabled = true;
    
   
} 
</script>

<?
$myArray = array();

$myArray = $HTTP_POST_VARS;


for ($i=0; $i< count($myArray); $i++)
{
	//print "$i";
	
	list($key, $value) = each($HTTP_POST_VARS);
	if (substr($key, 0, 5) == "image")
	{
		$image = substr($key, 5, -2);
		//print "<BR>image:  " . $image . "<BR>";
	}
	//echo"i am in first for";
}
$length = strlen($i-2);

//print "length is : " . $length;

for ($i=0; $i< count($myArray)-2; $i++)
{
	list($key1, $visitID) = each($myArray);
	$arrClientId = getArrayFromTable("er_visit","visit_id",$visitID);
	foreach($arrClientId as $value)
	$clientID = $value->client_id;
	
	
	if ((strtoupper(substr($key1, 5)) == strtoupper($image)) && (strtoupper(substr($key1,0,-1))=="VISITEDIT"))
	{
		//echo"<B>Visit ID : ".$visitID."</b>";
		
		$arrClient = getArrayFromTable("er_Client","client_id",$clientID);
		
		$resultVisit = getselectedVisitDetails($visitID);
		
		$visit_record = mysql_num_rows($resultVisit);
		
		echo"<h1>Edit Visit</h1>";
		if ($visit_record>0)
		{
			while ($rowVisit = mysql_fetch_array($resultVisit))
			{
				echo"<table width=\"100%\" border=\"0\"><tr><td align=\"right\" ><a href=\"#\" onClick=\"history.go(-1)\">Back</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#\" onClick=\"history.go(-2)\">Client Main Page</a></td></tr></table>";
				echo "<body background=\"./images/10/main.jpg\"><form name=form action=\"UpdateClientvisit1.php\" method=\"post\">"
				.""
				. "<table border=\"0\"> ";
				
				echo "<tr>" .
				"<td>Site Visited:</td>" .
				"<td><select name=\"cmbSite\">";
				//populateSelectedDropDownListBoxes("er_site",1,$rowVisit[1]);//PASS VALUE OF SELECTED SITE
				$query="SELECT * FROM er_site ORDER BY site_name";
				
				$results=r_db($query);
				
				while ($row=mysql_fetch_array($results))
				{
					if($row[$rowPosition]==$rowVisit[1])
					
					echo "<option selected>$row[1]</option>";
					
					else
					
					echo "<option>$row[1]</option>";
				}
				echo "</select>
			    </td>";
				
				$DbDOB=explode("-",$rowVisit[0]);

					$dayDOB=$DbDOB[2];

					$monthDOB=$DbDOB[1];

					$yearDOB=$DbDOB[0];

					$DOB=$dayDOB."/".$monthDOB."/".$yearDOB;
					
					
				echo  "<td>Visit Date</td>";

				echo "<td><input type=text name=txtVisitDate value=$DOB size='10' maxlength='10'  onKeyUp=DateFormat(this,this.value,event,false,'3') onBlur=DateFormat(this,this.value,event,true,'3');DatePosition(this.value,1)></td>";
					
					
				//generateTextBox("Visit Date", "text", "txtVisitDate", $DOB);
			  	echo "</tr>";
				
			  	foreach ($arrClient as $client)
			  	{
			  		echo "<td>Surname:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
			  		echo "<td>$client->surname</td>";
			  		echo "<td>Given:&nbsp;&nbsp;Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
			  		echo "<td>$client->givenName</td>";
			  		echo "<tr>";
			  	}
				echo "<tr>";
				
				echo "<input type=\"hidden\" name=\"txtCentreLinkAmount\" value=\"0\">";
				echo "</tr>";
				print "<input type=\"hidden\" name=\"visitID\" value=\"$visitID\">";
				echo "<input type=\"hidden\" name=\"txtVisitRecordedDate\">";
							
				echo "<tr>";
				echo "<td>Address:</td>";
				echo "<td><input type=\"text\" name=\"txtCurrentAddress\" value=\"$rowVisit[8]\"></td>";
				echo "<td>Suburb:</td>";
				echo "<td><input type=\"text\" name=\"txtCurrentSuburb\" value=\"$rowVisit[18]\"></td>";
				echo "</tr>";
				
				echo "<tr>";
				
				$arrStates = array("VIC","NSW","QLD", "ACT","NT", "WA", "SA", "TAS");
				echo "<td>State:&nbsp;&nbsp;&nbsp;</font></td>";
				echo "<td><select size=\"1\" name=\"txtCurrentState\">";
			
				foreach ($arrStates as $valueState)
				{
					if($rowVisit[19] == $valueState)
					{
						echo "<OPTION selected>$valueState</option>";
					}
					else
					{
						echo "<OPTION>$valueState</option>";
					}
				}
				
				
				echo  "<td>Post Code:</td>";

				echo "<td><input type=text name=txtCurrentPostCode value=$rowVisit[20]></td>";
				//generateTextBox("Post Code:", "text", "txtCurrentPostCode", $rowVisit[20]);
				echo "</tr>";
				
				
				echo "<tr>";
				
				
				echo  "<td>Phone Number</td>";

				echo "<td><input type=text name=txtPhone value=$rowVisit[10]></td>";
				//generateTextBox("Phone Number:", "text", "txtPhone", $rowVisit[10]);
				echo "<td>Mobile Number:</font></td>";
    			echo "<td>$client->mobile_no</td>";
				echo "</tr>";
				
				$DbDOB=explode("-",$client->dob);

					$dayDOB=$DbDOB[2];

					$monthDOB=$DbDOB[1];

					$yearDOB=$DbDOB[0];

					$DOB1=$dayDOB."/".$monthDOB."/".$yearDOB;
				
				
				echo "<td height=\"37\">Date Of Birth <font size=\"1\">(dd/mm/yyyy)</font></td>";
	    		echo "<td height=\"18\">$DOB1</td>";
	    		echo "<td width=\"5%\">Nationality:</td>";
	    		echo "<td>$client->nationality</td>";
				echo "</tr>";
				
				echo "<tr>";
	    		echo "<td height=\"34\">Gender:</font> </span></td>";
	    		echo "<td>$client->gender</td>";
	    		echo "<td>Preferred Language:</td>";
	    		echo "<td>$client->preferred_language</td>";
	  			echo "</tr>";
	  			
	  			echo "<tr>";
	  			
	  			echo "<td>ID Type:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></td>";
	  			$rowId = getFieldsFromLookUpTable("er_Identification_Type","identification_no",$client->identification_no);
	  			echo "<td>$rowId[1]</td>";
	  			echo "<td>Other (specify):</font></td>";
	  			echo "<tr>";
	  			echo "<td>ID Number:</td>";
	  			echo "<td>$client->id_reference_no</td>";
	  			
	  			echo "<tr>";
	  			
	  			
	  			echo  "<td>Children Assisted:*</td>";

				echo "<td><input type=text name=txtChildren value=$rowVisit[6]></td>";
				//generateTextBox("Children Assisted:*", "text", "txtChildren", $rowVisit[6]);
				
				
				echo  "<td>Adults Assisted:*</td>";

				echo "<td><input type=text name=txtAdults value=$rowVisit[7]></td>";
				//generateTextBox("Adults Assisted:*", "text", "txtAdults", $rowVisit[7]);
				echo "</tr>";
				
				echo "</table>";
				
				echo "<hr>";
				
					//=======================PAYMENT ON VISIT=============================
				echo "<h3><u>Assistance Provided</h3></u>";
				echo "<table border=\"0\">\n";
				echo "<tr>
		    	<td>ER Given:</td>";
				if ($rowVisit[21]=="Y")
				{
					echo "<td><input type=\"radio\" value=\"Y\" name=\"optErGiven\" checked onfocus=\"enableassistance('form','payment[]')\">Yes &nbsp;&nbsp;&nbsp;";
					echo "<input type=\"radio\" value=\"N\" name=\"optErGiven\" onfocus=\"disableassistance('form','payment[]')\" >No</td>";
				}
				else
				{
					echo "<td><input type=\"radio\" value=\"Y\" name=\"optErGiven\" onfocus=\"enableassistance('form','payment[]')\">Yes&nbsp;&nbsp;&nbsp;";
					echo "<input type=\"radio\" value=\"N\" name=\"optErGiven\" checked onfocus=\"disableassistance('form','payment[]')\">No</td>";
				}
				echo "</tr>";
				
				$clientPayments = getArrayFromTable("er_Payment_On_Visit","visit_id",$visitID);
				foreach ($clientPayments as $entry)
				{
					
					echo "<tr>\n";
					$rowPayment = getFieldsFromLookUpTable("er_payment","payment_id",$entry->payment_id);
					echo "<td>$rowPayment[1]:</td>";
					echo "<td><input type=\"textbox\" name=\"payment[]\" value=\"$entry->payment_amount\" size=\"5\">";
					//if($rowPayment[1]=="Cheque")
					//{
						
					//}
					
				}
				echo "<td>Other Payment Type:</td>";
				echo "<td><input type=\"textbox\" name=\"txtOtherPaymentType\" value=\"$entry->other_payment_type\">";
				echo "</tr>\n";
				echo "<tr>\n";
				echo "<td>ChequePayee (for cheques only):</td>";
				echo "<td><input type=\"textbox\" name=\"txtChequePayee\" value=\"$entry->cheque_payee\">";
				echo "<td>Cheque No:</td>";
				echo "<td><input type=\"textbox\" name=\"txtErAmountRecieptNo\" value=\"$entry->er_amount_receipt_no\">";
				echo "</tr>\n";
				echo "<tr>\n";
				echo "<td>Reason for Cheque Payment:</td>";
				echo "<td><input type=\"textbox\" name=\"txtReasonChequePayment\" value=\"$entry->reason_cheque_payment\">";
				echo "</tr>";
				echo "</table>\n";
				
				echo "<hr>";
				
				//==================Income Source======================
				echo "<h3><Sources of Household Incomes</h3>";
				
				echo "<table>\n";
				$client_income = getArrayFromTable("er_client_income", "visit_id",$visitID);
				$countClientIncome = count($client_income);
				
				$incomes_source = get_labels("er_income_source");
				
				$html_incomes = make_html($incomes_source, $client_income, 3, 400, "incomes[]", "amount[]","whenDue[]");
				
				if($countClientIncome==3)
				echo "$html_incomes";
				else
				{				
					$loops =  3-$countClientIncome;
					for ($count=1;$count<=$loops;$count++)
					{
											
							echo "<tr>";
							echo "<td>";
							echo "<select name=incomes[]>";
							//populateDropDownListBoxes("er_income_source", 1, "income_type");
							echo "<option>Select Client Income</option>";
							$query="SELECT * FROM er_income_source ORDER BY income_type" ;
							
							$results=r_db($query);
							
							while ($row=mysql_fetch_array($results))
							
							{
								if ($row[1]!="Other" && $row[1]!="Select Client Income")
								echo "<option>$row[1]</option>";
								
							}
							echo "<option>Other</option>";
							echo "</select>";
							echo "</td>";
							echo  "<td><input type=\"text\" name=\"amount[]\" value=\"\"></td>\n";
							echo  "<td><input type=\"text\" name=\"whenDue[]\"  value=\"\" size='10' maxlength='10'  onKeyUp=\"DateFormat(this,this.value,event,false,'3')\" onBlur=\"DateFormat(this,this.value,event,true,'3');DatePosition(this.value,1)\" ></td>\n";
							echo "</tr>";
						
					}
				}
				
				
				echo  "<td>Other (specify)</td>";

				echo "<td><input type=text name=txtOtherIncomeSourceType value=$rowVisit[25]></td>";
				//generateTextBox("Other (specify):", "text", "txtOtherIncomeSourceType", $rowVisit[25]);
				echo "</table>";
				
				echo "<hr>";
				
				echo "<table>";
				
				echo "<tr>";
				echo "<td width=\"29%\">Income Status:</td>";
				echo "<td><select name=\"cmbIncomeStatus\">";
				populateSelectedDropDownListBoxes("er_income_status",1, $rowVisit[11], "income_status_type");
				echo "</select>";
				echo "</td>";
				
				echo  "<td>Other (specify):</td>";

				echo "<td><input type=text name=txtOtherIncomeStatusType value=$rowVisit[16]></td>";
				//generateTextBox("Other (specify):", "text", "txtOtherIncomeStatusType", $rowVisit[16]);
				//echo "<td>Other (specify):</td>";
				//echo "<td><input type=\"text\" value=\"$rowVisit[16]\" name=\"txtOtherIncomeStatusType\"></td>";
				echo "</tr>";
				
				echo "<tr>";
				echo "<td>Housing Type:</td>";
				echo "<td><select name=\"cmbHousingType\" >";
				populateSelectedDropDownListBoxes("er_housing_type",1, $rowVisit[9],"housing_type" );
				echo "</select>";
				echo "</td>";
				
				
				echo  "<td>Other (specify):</td>";

				echo "<td><input type=text name=txtOtherHousingType value=$rowVisit[12]></td>";
				//generateTextBox("Other (specify):", "text", "txtOtherHousingType", $rowVisit[12]);
				echo "</tr>";
				
				echo "<tr>";
				
				echo  "<td>Rent paid per fortnight:</td>";

				echo "<td><input type=text name=txtFortnightlyPayments value=$rowVisit[14]></td>";
				//generateTextBox("Rent paid per fortnight:", "text", "txtFortnightlyPayments", $rowVisit[14]);
				echo "</tr>";
				
				echo "<tr>";
				echo "<td>Client Referred By:</td>";
				echo "<td><select name=\"cmbAgency\">";
				populateSelectedDropDownListBoxes("er_agency",1, $rowVisit[15], "agency_name");
				echo "</select>";
				echo "</td>";
				echo "</tr>";
				
				echo "</table>";
				//================Emergency Relief=========================
				
				//echo "<table widhth=\"100%\">";
				$reliefs = get_labels("er_Emergency_Relief");
				
				$checkedEr = getArrayFromTable("er_Relief_On_Visit","visit_id",$visitID);
				//print_r($checkedEr);
				$html_reliefs = make_er_checkbox_html($reliefs, 4, 400, "emergencyReliefs[]", $checkedEr);
				
				echo "<hr><h3><u>Reasons for Seeking Assistance</h3></u>";
				//echo "<table>";
				//echo "<tr>";
							
				echo "$html_reliefs";
				
				//echo "<tr>";
				
				echo  "<td>Other (specify):</td>";

				echo "<td><input type=text name=txtOtherEr value=$rowVisit[23]></td>";
				//generateTextBox("Other (specify):", "text", "txtOtherEr", $rowVisit[23]);
				
				echo "</tr>";
				echo "</table>";
				echo "<br>";
				echo "<table>";
				
				echo "<hr><tr>";
				echo "<td width=\"28%\" colspan=\"2\" height=\"35\">Presenting Problem and other issues (ER):*</font> </span></td>";
				echo "<td colspan=\"2\"><textarea rows=\"5\" name=\"txtErReason\" cols=\"50\" onchange=\"remove_XS_whitespace(this)\" onblur=\"return changeCase(this)\">$rowVisit[22]</textarea></td>";
				//generateTextBox("Presenting Problem and other issues (ER)", "textarea", "txtErReason", $rowVisit[22]);
				echo "</tr>";
				
				echo "<tr>";
				//generateTextBox("Action Taken", "textarea", "txtActionTaken", $rowVisit[3]);
				echo "<td colspan=\"2\">Action Taken:*</td>";
				echo "<td colspan=\"2\"><textarea rows=\"5\" name=\"txtActionTaken\" cols=\"50\" onchange=\"remove_XS_whitespace(this)\" onblur=\"return changeCase(this)\">$rowVisit[3]</textarea></td>";
				echo "</tr>";
				
				echo "<tr>";
				//generateTextBox("Day Book Color:", "text", "txtDayBookColor", $rowVisit[4]);
				//generateTextBox("Day Book Page No:", "text", "txtDayBookPageNo", $rowVisit[5]);
				echo "<td><input type=\"hidden\" value=\"$rowVisit[4]\" name=\"txtDayBookColor\" >";
				echo "<td><input type=\"hidden\" value=\"$rowVisit[4]\" name=\"txtDayBookPageNo\" >";
				echo "</tr>";
				
				echo "<tr>
		    	<td colspan=\"2\">Client Signature:</td>";
				if ($rowVisit[24]=="Y")
				{
					echo "<td><input type=\"radio\" value=\"Y\" name=\"optClientSignature\" checked>Yes";
					echo "<input type=\"radio\" value=\"N\" name=\"optClientSignature\">No";
				}
				else
				{
					echo "<td><input type=\"radio\" value=\"Y\" name=\"optClientSignature\">Yes";
					echo "<input type=\"radio\" value=\"N\" name=\"optClientSignature\" checked>No";
				}
				echo "</tr>";
				
				echo "<tr>";
				//generateTextBox("Interviewer:*", "text", "txtInterviewer", $rowVisit[2]);
				echo "<td colspan=\"2\">Interviewer:*</td>";
				echo "<td><input type=\"text\" value=\"$rowVisit[2]\" name=\"txtInterviewer\" >";
				echo "</tr>";
				echo "</table>";
				
				
				echo "<hr>";
				//echo "<input type=button value=\"Update\"  onclick=\"javascript:verify();\">";
				echo "<input type=button value=\"Update\"  onclick=\"verify();\">";
				echo "</form>";
				echo"</body>";
				echo"</html>";
				
			}
		}
		else echo "No visits found for this client!";
		
		
		
	}// END OF EDIT VISIT
	
	//if (substr($key1, 5, -$length) == "Dele")
	if ((strtoupper(substr($key1, 5)) == strtoupper($image)) && (strtoupper(substr($key1,0,-1))=="VISITDELE"))
	{
		//print "this is DELETE";
		
		//echo $visitID;
		$query = "SELECT * FROM er_visit WHERE visit_id=$visitID";
		//echo $query;
		$sql = r_db($query);
		
		$result = mysql_num_rows($sql);
		//echo "hello";
		if($result > 0)
		{
			//echo "i am in result";
			//deleteRecordWithPK("er_client","client_id",$clientID);
			echo"<table width=\"100%\" border=\"0\"><tr><td align=\"right\" ><a href=\"#\" onClick=\"history.go(-2)\">Client Main Page</a></td></tr></table>";					
			deleteRecordWithPK("er_visit","visit_id",$visitID);
			deleteRecordWithPK("er_client_income","visit_id",$visitID);
			deleteRecordWithPK("er_payment_on_visit","visit_id",$visitID);
			deleteRecordWithPK("er_relief_on_visit","visit_id",$visitID);
			//deleteRecordWithPK("er_visit","visit_id",$visitID);
			
			
			$query="SELECT * FROM er_visit where visit_id='$visitID'";
			
			echo "Visit has been successfully deleted";
			
			$results=r_db($query);
			
			
			while ($row=mysql_fetch_array($results))
			{
				//echo "val is: 	$row[0]";
				deleteRecordWithPK("er_client_income","visit_id",$row[0]);
			}
		}
	
		
	}//END OF DELETE VISIT
	
}

function make_html($incomes_source, $client_income, $num, $width, $name,$name1,$name2)
	{
		
		echo "<table width=\"$width\" border=\"0\">\n";
		echo "<tr>\n";
		echo  "<th>Income Type</th>";
		echo "<th>Amount</th>";
		echo "<th>When Due</th>";
		echo  "</tr>";
		
		foreach ($client_income as $entry)
		{
			echo "<tr>";
			echo "<td>";
			$rowIncomeType = getFieldsFromLookUpTable("er_income_source","income_id",$entry->income_id);
			echo "<select name=$name>";
			//populateSelectedDropDownListBoxes("er_income_source",1,$rowIncomeType[1], "income_type");
			$query="SELECT * FROM er_income_source ORDER BY income_type";
		
			$results=r_db($query);
			
			if($rowIncomeType[1]=="Select Client Income")
				echo "<option selected>Select Client Income</option>";
			else
				echo "<option>Select Client Income</option>";
			
			while ($row=mysql_fetch_array($results))
			{
				if ($row[1]!="Other" && $row[1]!="Select Client Income")
				{
					if($row[1]==$rowIncomeType[1])
						echo "<option selected>$row[1]</option>";
					else
						echo "<option>$row[1]</option>";
				}
					
			}
			if($rowIncomeType[1]=="Other")
				echo "<option selected>Other</option>";
			else
				echo "<option>Other</option>";
				
			echo "</select>";
			echo "</td>";
			echo  "<td><input type=\"text\" name=\"$name1\" value=\"$entry->income_amount\"></td>\n";
			
			$DbDOB=explode("-",$entry->when_due);

					$dayDOB=$DbDOB[2];

					$monthDOB=$DbDOB[1];

					$yearDOB=$DbDOB[0];

					$DueDB=$dayDOB."/".$monthDOB."/".$yearDOB;
			
			echo  "<td><input type=\"text\" name=\"$name2\"  value=\"$DueDB\" size='10' maxlength='10'  onKeyUp=\"DateFormat(this,this.value,event,false,'3')\" onBlur=\"DateFormat(this,this.value,event,true,'3');DatePosition(this.value,3)\"></td>\n";
			echo "</tr>";
			
		}
		
		
	}
	


function make_er_checkbox_html($arr, $num, $width, $name, $checked)
{
	$closingTR = false;
	$str = "";
	$str .= "<tr>\n";
	if (count($arr) % $num != 0)
	{
		$closingTR = true;
	}
	
	$i=1;
	
	$str = "";
	$str .= "<table width=\"100%\" border=\"0\">\n";
	//$str .= "<th>Reason for seeking assistance</th>";
	$str .= "<tr>\n";
	
	if (isset($checked))
	{
		//    /* if we passed in an array of the checkboxes we want
		//       to be displayed as checked */
		foreach ($arr as $ele)
		{
			//$str .= "<td><input type=\"checkbox\" name=\"$name\" value=\"$ele->id\"";
			$str .= "<td><input type=\"checkbox\" name=\"$name\" value=\"$ele->er_id\"";
			foreach ($checked as $entry)
			{
				if ($entry->relief_id == $ele->er_id)
				{
					$str .= "checked";
					continue;//skip rest of current loop, continue execution at beginning of the next iteration
				}
			}
			$str .= ">";
			$str .= "$ele->er_reason\n</td>";
			//$str .= "</tr>";
			if ($i % $num == 0)
			{
				$str .= "</tr>\n<tr>";
			}
			else
			{
				$str .= "</td>\n";
			}
			$i++;
			
			
		}
	}
	//$str .= "</table>\n";
	return $str;
}




function getselectedVisitDetails($visitId)
{
	$queryVisitDate = "SELECT
						  
						  er_visit.visit_date,
						  er_visit.site_visited_id,
						  er_visit.interviewer,
	  					  er_visit.action_taken,
						  er_visit.day_book_colour, 
						  er_visit.day_book_page_no, 
						  er_visit.no_children_assistted, 
						  er_visit.no_adults_assistted,
						  er_visit.address,
						  er_housing_type.housing_type,
						  er_visit.phone_no,
						  er_income_status.income_status_type,
						  er_visit.other_housing_type,
						  er_visit.centrelink_loan_amt_borrowed,
						  er_visit.rent_paid_pf,
						  er_agency.agency_name,
						  er_visit.other_income_status,
						  er_visit.visit_recorded_date,
						  er_visit.suburb,
						  er_visit.state,
						  er_visit.postcode,
						  er_visit.er_given,
						  er_visit.er_reason,
						  er_visit.other_er,
						  er_visit.client_signature,
						  er_visit.other_income_source
						  FROM er_visit,er_housing_type,er_income_status,er_agency
						  WHERE er_visit.housing_type_id=er_housing_type.housing_type_id 
						  AND er_visit.income_status_id=er_income_status.income_status_id
						  AND er_visit.agency_id=er_agency.agency_id
						  AND er_visit.visit_id=$visitId";
	
	$resultVisit = r_db($queryVisitDate);
	//echo $queryVisitDate;
	return $resultVisit;
	
}

?>
		